package Builder;

/**
 * Created by wangyg 
 * on 2017/6/12 11:38
 */
public class Person {
	private Integer age;
	private String name;

	private Person(Builder builder) {
		this.age = builder.age;
		this.name = builder.name;
	}

	@Override
	public String toString() {
		return "Person{" +
				"age=" + age +
				", name='" + name + '\'' +
				'}';
	}

/*
	public Person() {
	}
*/

	private static class Builder {
		private Integer age;
		private String name;

		public Builder name(String name) {
			this.name = name;
			return this;
		}

		public Builder age(Integer age) {
			this.age = age;
			return this;
		}

		public Person build() {
			return new Person(this);
		}
	}

	public static void main(String[] args) {
		Builder builder = /*new Person().*/new Person.Builder();
		Person xiaoming = builder.age(12).name("xiaoming").build();
		System.out.println(xiaoming);


	}
}
